package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.Collect;
import cn.wolfcode.trip.base.mapper.CollectMapper;
import cn.wolfcode.trip.base.query.CollectQueryObject;
import cn.wolfcode.trip.base.service.ICollectService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class CollectServiceImpl implements ICollectService {
    @Autowired
    private CollectMapper collectMapper;

    public PageInfo queryForTravel(CollectQueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize(), qo.getOrderBy());
        return new PageInfo(collectMapper.queryForTravel(qo));
    }

    public PageInfo queryForNews(CollectQueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize(), qo.getOrderBy());
        return new PageInfo(collectMapper.queryForNews(qo));
    }

    public Collect selectById(CollectQueryObject qo) {
        return collectMapper.selectById(qo);
    }

    public void delete(CollectQueryObject qo) {
        collectMapper.delete(qo);
    }

    public void saveTravel(CollectQueryObject qo) {
        qo.setCollectTime(new Date());
        collectMapper.saveTravel(qo);
    }
}
